# -*- coding:utf-8 -*-
# -------------------------------------------------------------------------------
# Description:  
# Reference:
# Author: 安智军
# Date:   2021/12/15
# -------------------------------------------------------------------------------
import logging
import time
import os
from config.config import basepath

log_path = basepath+"/Outputs/logs/"
if not os.path.exists(log_path):
    os.mkdir(log_path)


# 封装自己的logging
class MyLogger:
    def __init__(self):
        self.logname = log_path+"{}.log".format(time.strftime("%Y%m%d"))
        self._logger = logging.getLogger("logger")
        self._logger.setLevel(logging.DEBUG)
        self._formatter = logging.Formatter('[%(asctime)s][%(filename)s %(lineno)d][%(levelname)s]:%(message)s')
        self._streamHandler = logging.StreamHandler()
        self._fileHandler = logging.FileHandler(self.logname, mode='a', encoding="utf-8")
        self._streamHandler.setFormatter(self._formatter)
        self._fileHandler.setFormatter(self._formatter)
        self._logger.addHandler(self._streamHandler)
        self._logger.addHandler(self._fileHandler)

    # 获取logger日志记录器
    def get_logger(self):
        return self._logger


logger = MyLogger().get_logger()
logger.info("""
                 _    _         _      _____         _
  __ _ _ __ (_)  / \\  _   _| |_ __|_   _|__  ___| |_
 / _` | '_ \\| | / _ \\| | | | __/ _ \\| |/ _ \\/ __| __|
| (_| | |_) | |/ ___ \\ |_| | || (_) | |  __/\\__ \\ |_
 \\__,_| .__/|_/_/   \\_\\__,_|\\__\\___/|_|\\___||___/\\__|
      |_|
      Starting     ...  wms接口自动化执行中...  ...  知道的越多，不知道的越多   ...
    """)
if __name__ == '__main__':
    pass
    # logger.info("222")
    # logger.error("333")